﻿using Application.IAppSrevices;
using Domain.Entitys;
using Microsoft.AspNetCore.Mvc;
using UI.Hubs;

namespace UI.Controllers
{
    public class MCController : Controller               
    {

        private readonly IMCService mCService;

        public MCController(IMCService mCService)
        {
            this.mCService = mCService;
        }
        public IActionResult Index()
        {
            return View();
        }
        private static int hufId;
        public IActionResult MCAddYm(int id)
        {
            string userName = HttpContext.Session.GetString("UTrueName");
            ViewBag.UserTrueName = userName;
            hufId = id;
            return View();
        }

        [HttpGet]
        public IActionResult HFDFenYe(int a, int b, string? s1, DateTime? s2, DateTime? s3)
        {
            return Json(mCService.HFDFenYe(a, b, s1, s2, s3));
        }

        [HttpGet]
        public IActionResult HFDCount(string? s1, DateTime? s2, DateTime? s3)
        {
            return Json(mCService.HFDCount(s1, s2, s3));
        }

        [HttpGet]
        public async Task<IActionResult> GetHFDById()
        {
            return Json(await mCService.GetHFDById(hufId));
        }

        [TypeFilter(typeof(SingarFilterAttribute), Arguments = new object[] { "调动管理" })]
        [HttpPost]
        public async Task<IActionResult> MCAdd(MC mc)
        {
            return Json(await mCService.MCAdd(mc));
        }

        //5-2
        public IActionResult Index2()
        {
            return View();
        }

        private static int mchId;
        public IActionResult MCUpdateYm(int id)
        {
            mchId = id;
            string userName = HttpContext.Session.GetString("UTrueName");
            ViewBag.UserTrueName = userName;
            return View();
        }

        [HttpPut]
        public IActionResult HFDUpdate(int id, string fd, string fn, string sd, string sn, string td, string tn, string kd, string kn, string md, string mn, string salary)
        {
            return Json(mCService.HFDUpdate(id, fd, fn, sd, sn, td, tn, kd, kn, md, mn, salary));
        }

        [HttpGet]
        public IActionResult MCFenYe(int a, int b, string? s1, DateTime? s2, DateTime? s3)
        {
            return Json(mCService.MCFenYe(a, b, s1, s2, s3));
        }

        [HttpGet]
        public IActionResult MCCount(string? s1, DateTime? s2, DateTime? s3)
        {
            return Json(mCService.MCCount(s1, s2, s3));
        }

        [HttpGet]
        public async Task<IActionResult> GetMCById()
        {
            return Json(await mCService.GetMCById(mchId));
        }

        [HttpPut]
        public IActionResult MCUpdate(MC mc)
        {
            return Json(mCService.MCUpdate(mc));
        }

        //5-3
        public IActionResult Index3()
        {
            return View();
        }

        [HttpGet]
        public IActionResult MCFenYe2(int a, int b, string? s1, DateTime? s2, DateTime? s3)
        {
            return Json(mCService.MCFenYe2(a, b, s1, s2, s3));
        }

        [HttpGet]
        public IActionResult MCCount2(string? s1, DateTime? s2, DateTime? s3)
        {
            return Json(mCService.MCCount2(s1, s2, s3));
        }

        public IActionResult MCSelectYm(int id)
        {
            mchId = id;
            return View();
        }
    }
}
